package io.packaging;

import java.io.*;

public class Speed {
    public static void main(String[] args) {

speed2();
speed3();
speed4();
}
public static final String SRC="C:\\Users\\赵帆\\Desktop\\新建文件夹 (2)\\植物大战僵尸杂交版v2.3\\植物大战僵尸杂交版v2.3安装程序.exe";
    public static final String SSR="C:\\Users\\赵帆\\Desktop\\范例\\a.exe";
    public static void speed1()
    { long startime=System.currentTimeMillis();
        {
            try (FileInputStream A = new FileInputStream( SRC);
                 FileOutputStream A1 = new FileOutputStream(SSR);
            ) {
                int a1;
                while ((a1 = A.read()) != -1) {
                    A1.write(a1);
                }

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            long endtime=System.currentTimeMillis();
            System.out.println("低字节单个赋值时间"+(endtime-startime)/1000+"s");
        }
    }
    public static void speed2()
    {
        long startime=System.currentTimeMillis();
        try (FileInputStream   A =new  FileInputStream(SRC);
             FileOutputStream  B=new FileOutputStream(SSR))
        {
           byte[]s=new byte[1024];
            int a1;
            while ((a1 = A.read(s)) != -1) {
                B.write(a1);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        long endtime=System.currentTimeMillis();
        System.out.println("低字节数组赋值时间"+(endtime-startime)/1000+"s");
    }
    public static void speed3()
    {
        long startime=System.currentTimeMillis();
        {
            try (FileInputStream A = new FileInputStream( SRC);
                 BufferedInputStream B=new BufferedInputStream(A);
                 FileOutputStream A1 = new FileOutputStream(SSR);
                 BufferedOutputStream B1=new BufferedOutputStream(A1)
            ) {
                int a1;
                while ((a1 = B.read()) != -1) {
                    B1.write(a1);
                }

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            long endtime=System.currentTimeMillis();
            System.out.println("缓冲流单个赋值时间"+(endtime-startime)/1000+"s");
        }
    }
    public static void speed4()
    {
        long startime=System.currentTimeMillis();
        try (FileInputStream   A =new  FileInputStream(SRC);
             BufferedInputStream A1=new BufferedInputStream(A);
             FileOutputStream  B=new FileOutputStream(SSR);
             BufferedOutputStream B1=new BufferedOutputStream(B);
        )

        {
            byte[]s=new byte[1024];
            int a1;
            while ((a1 = A.read(s)) != -1) {
                B.write(a1);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        long endtime=System.currentTimeMillis();
        System.out.println("缓冲流数组赋值时间"+(endtime-startime)/1000+"s");

    }

}